# $Id: PKGBUILD 135033 2011-08-09 23:31:20Z eric $
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgbase=flac
pkgname=('flac' 'flac-doc')
pkgver=1.2.1
pkgrel=3
arch=('i686' 'x86_64')
url="http://flac.sourceforge.net/"
license=('BSD' 'GPL')
depends=('libogg')
makedepends=('nasm' 'xmms')
options=('!libtool' '!makeflags')
source=(http://downloads.sf.net/sourceforge/${pkgbase}/${pkgbase}-${pkgver}.tar.gz 
	flac-1.2.1-gcc-4.3-includes.patch)
md5sums=('153c8b15a54da428d1f0fadc756c22c7'
         'b9d245422bbc547b18a72897366bea77')
sha1sums=('bd54354900181b59db3089347cc84ad81e410b38'
          '7e9f8c2ef4d9daf5ddd20df63b608fe19b8c1560')

build() {
  cd "${srcdir}/${pkgbase}-${pkgver}"
  patch -Np1 -i "${srcdir}/flac-1.2.1-gcc-4.3-includes.patch"
  ./configure --prefix=/usr --mandir=/usr/share/man --enable-shared \
    --disable-sse --disable-rpath --with-pic
  make
}

check() {
  cd "${srcdir}/${pkgbase}-${pkgver}"
  make check
}

package_flac() {
  pkgdesc="Free Lossless Audio Codec"
  optdepends=('xmms: for using the xmms plugin')
  options=('!libtool' '!docs')

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -D -m644 COPYING.Xiph "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

package_flac-doc() {
  pkgdesc="Developer documentation for the Free Lossless Audio Codec"
  depends=('flac')

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make DESTDIR="${pkgdir}" -C doc install
  install -D -m644 COPYING.Xiph "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
